<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>持仓</title>
    <link rel="stylesheet" type="text/css" href="/static/index_user/css/aui_1.css" />
    <link rel="stylesheet" type="text/css" href="/static/index_user/css/aui-slide_1.css" />
    <style type="text/css">.aui-list .aui-list-header {
        background-color: #ffffff;
        text-align: center;
        justify-content: center;
        border-bottom: 1px solid #dddddd;
        font-size: 1rem;
    }

    .aui-grid [class*=aui-col-] {
        padding: 0.2rem 0;
        text-align: left;
    }

    .aui-list label {
        line-height: 1.8rem;
        width: 200px;
    }</style>
</head>

<body>
<header class="aui-bar aui-bar-nav" style="position: fixed;">
    <a class="aui-pull-left aui-btn">

    </a>
    <div class="aui-title">持仓</div>
</header>
<div id="msg" class="" style=" display: none; width: 100%;position: fixed;top: 6%;z-index: 99;color: red;background-color: yellow;text-align: center">您有新消息,请在消息中心查看</div>
<div class="aui-tab" id="tab" style="margin-top: 48px;">

    <div class="aui-tab-item  aui-active">
        持仓平仓
    </div>
    <div class="aui-tab-item"><a href="{:url('user/Chicang/jiaogedan')}" style="color:#ffffff">交割单</a></div>
</div>
<div class="aui-content aui-margin-t-15 aui-margin-b-15" style="margin-bottom:2.5rem !important;">
    <ul class="aui-list aui-select-list" id="partAjaxData">
        {volist name="data" id="v"}
        <li class="aui-list-item">


            <div class="aui-list-item-inner">
                <section class="aui-grid">
                    <div class="aui-row">
                        <div class="aui-row">

                            <span>{$v.stock['name']}--{$v.stock['name']}</span>
                        </div>
                        <div class="aui-row">
                            <span>交易号：</span><span>{$v.ordernum}</span>
                        </div>
                        <div class="aui-col-xs-12">
                            <span>买入时间：</span><span>{:date('Y-m-d H:i:s',$v.time)}</span>
                        </div>
                        <div class="aui-col-xs-6">
                            <span>买入价：</span><span>{$v.buyprice}</span>
                        </div>
                        <div class="aui-col-xs-6">
                            <span>现价：</span><span>{$v.stock['sellprice']}</span>
                        </div>

                        <div class="aui-col-xs-6">
                            <span>持有数量：</span><span>{$v.count}</span>
                        </div>

                        <!--<div class="aui-col-xs-6">-->
                        <!--<span>询价方向：</span><span><font color="red">买涨</font></span>-->
                        <!--</div>-->
                        <div class="aui-col-xs-6">
                            <span>交易周期：</span><span>{$v.jyzq}</span>
                        </div>
                        <div class="aui-col-xs-6">
                            <span>盈利：</span><span>{$v.yk}</span>
                        </div>

                        <div class="aui-row" style="width: 100%;">
                            <div class="aui-col-xs-3" style="margin-top:10px;margin-bottom:10px;text-align:right">
                                <!--<a href="javascript:void(0);" class="kc">-->
                                <!--<button class="aui-btn delbtn" style="border:none; width:100%;height:40px;color:#ffffff;line-height:40px;margin-right:5px;background-color: red !important;"  data_id="{$v.id}"  >出售</button>-->
                                <!--</a>-->
                            </div>
                            <div class="aui-col-xs-6" style="margin-top:10px;margin-bottom:10px;text-align:left">
                                <button class="aui-btn sellbtn" style="border:none;width:100%;height:40px;color:#ffffff;line-height:40px;margin-left:5px;background-color: green !important;" data_id="{$v.id}">立即卖出</button>

                            </div>

                        </div>


                    </div>
                </section>

            </div>
        </li>


        {/volist}








    </ul>
</div>

<footer class="aui-bar aui-bar-tab" id="footer">
    <div class="aui-bar-tab-item aui-active">
        <a href="{:url('user/Index/index')}" style="color:#757575">
            <i class="aui-iconfont aui-icon-home"></i>
            <div class="aui-bar-tab-label">首页</div>
        </a>
    </div>
    <div class="aui-bar-tab-item">
        <a href="{:url('user/Xunjia/index')}" style="color:#757575">
            <i class="aui-iconfont aui-icon-cert"></i>
            <div class="aui-bar-tab-label">询价</div>
        </a>
    </div>
    <div class="aui-bar-tab-item">
        <a href="{:url('user/Chicang/index')}" style="color:#ffffff">
            <i class="aui-iconfont aui-icon-image"></i>
            <div class="aui-bar-tab-label">持仓</div>
        </a>
    </div>

    <div class="aui-bar-tab-item">
        <a href="{:url('user/UserCenter/index')}" style="color:#757575">
            <i class="aui-iconfont aui-icon-my"></i>
            <div class="aui-bar-tab-label">我的</div>
        </a>
    </div>
</footer>
</body>
<script type="text/javascript" src="/static/index_user/js/api_1.js"></script>
<script type="text/javascript" src="/static/index_user/js/aui-tab_1.js"></script>
<script type="text/javascript" src="/static/index_user/js/aui-slide_1.js"></script>
<script type="text/javascript" src="/static/index_user/js/jquery-1.11.3.min.js"></script>
<script>

    $('.sellbtn').click(function () {
        var ac_id=$(this).attr('data_id');
        console.log(ac_id);
        var obj = $(this).parents('li');

        $.ajax({
            type: 'post',
            url: '/sell',
            dataType: 'json',
            data:{'id':ac_id},
            success: function (data) {
                console.log(data);
                if (data[0]==1) {
                    alert(data[1]);
                    obj.remove();

                } else {
                    alert(data[1]);

                }
            },
            error: function () {
                alert('AJAX操作失败');
            }
        });
    });


//    //刷新页面数据的方法
//    function sx() {
//        clearTimeout(time);
//        $.post("/index.php/Business/partAjaxData.html", {
//            'page': 1
//        }, function(result) {
//            var str = '';
//            if (result.code == 1 && result.data!=null) {
//                for (i = 0; i < result.data.length; i++) {
//                    bb = "/index.php/Bullish/Attention.html?stockcode=" + result.data[i]['stockcode']+"&status=1";
////						str += "<tr style='background: #FFFFFF'>" +
////							"<td>" + result.data[i]['no'] + "</td>" +
////							"<td>" + result.data[i]['opentime'] + "</td>" +
////							"<td>" + result.data[i]['dqtime'] + "</td>" +
////							"<td>" + result.data[i]['jyzq'] + "</td>" +
////							"<td>" + result.data[i]['stockcode']+"/" + result.data[i]['stockname']+ "</td>" +
////							"<td>" +((result.data[i]['type'] == 1)? '<font color="red">买涨</font>' : '<font color="green">买跌</font>') +"</td>" +
////							"<td>" + Number(result.data[i]['openprice']).toFixed(2)+ "</td>" +
////							"<td>" + result.data[i]['num'] + "</td>" +
////							"<td>" + result.data[i]['credit'] + "</td>" +
////							"<td>" + Number(result.data[i]['dqprice']).toFixed(2) + "</td>" +
////							"<td>" + Math.round(result.data[i]['fdshouyi']*100)/100 + "</td>" +
////							//"<td>" + Math.round(result.data[i]['keepfee']*100)/100 + "</td>" +
////
////							"<td>" +((result.data[i]['status'] == 0)? '<a class=\"jiaoyi\" href=\"/index.php/Business/pingcang.html?eid='+result.data[i]['eid']+'\" ><span class=\"b\" style=\"background: #1A80F2;box-shadow: 0 0 5px 2px #398FEA inset;\">平仓</span></a>' : '<a class="jiaoyi" href="javascript:void(0)" ><span class="nb">平仓</span></a>') +"</td>" +
////							"</td></tr>";
//
//                    str=str+'<li class="aui-list-item">';
//                    str=str+'<div class="aui-list-item-inner">';
//                    str=str+'<section class="aui-grid">';
//                    str=str+'<div class="aui-row">';
//                    str=str+'<div class="aui-col-xs-11">';
//                    str=str+'<span style="color:red">'+ result.data[i]['stockcode']+"--" + result.data[i]['stockname']+ '</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-11">';
//                    str=str+' <span>交易号：</span><span>'+result.data[i]['no']+'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-11">';
//                    str=str+'<span>下单时间：</span><span>'+ result.data[i]['opentime'] +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>到期时间：</span><span>'+ result.data[i]['dqtime'] +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>交易周期：</span><span>'+ result.data[i]['jyzq'] +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>类型：</span><span>'+((result.data[i]['type'] == 1)? '<font color="red">买涨</font>' : '<font color="green">买跌</font>') +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>成交价：</span><span>'+Number(result.data[i]['openprice']).toFixed(2)+'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>数量(手)：</span><span>'+ result.data[i]['num'] +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>成交额：</span><span>'+ result.data[i]['credit'] +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span>现价：</span><span>'+ Number(result.data[i]['dqprice']).toFixed(2) +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-6">';
//                    str=str+'<span style="color:red">浮动盈亏：</span><span style="color:red">'+ Math.round(result.data[i]['fdshouyi']*100)/100 +'</span>';
//                    str=str+'</div>';
//                    str=str+'<div class="aui-col-xs-11" style="text-align:center;width:100%">';
//
//                    if(result.data[i]['status'] == 0){
//                        str=str+' <a href=/index.php/Business/pingcang.html?eid='+result.data[i]['eid']+'>';
//                        str=str+'<div class="aui-btn aui-btn-info" style="width:100px;height:40px;line-height:40px;">平仓</div>';
//                        str=str+'</a>';
//                    }else{
//                        str=str+'<div class="aui-btn" style="width:100px;height:40px;line-height:40px;">平仓</div>';
//                    }
//
//                    str=str+'</div>';
//                    str=str+'</div>';
//                    str=str+'</section>';
//                    str=str+'</div>';
//                    str=str+'</li>';
//                }
//                $('#partAjaxData').html(str);
//                time = setTimeout('sx()',1000);
//                //console.log(result)
//            } else {
//                str='<div style="margin-bottom:15px;background-color:#2c3039;height:100px;vertical-align:middle;text-align:center;display:flex;align-items:center;justify-content:center;color:#ffffff">';
//                str=str+"暂无数据";
//                str=str+'</div>';
//                $('#partAjaxData').html(str);
//            }
//        })
//    }
//    //sx();
//    time = setTimeout('sx()', 10);


</script>
</html>

<script>
    showmsg();
    function showmsg() {
//        var $=jQuery;
//        console.log($);
        $.ajax({
            type: 'get',
            url: '/msg',
            dataType: 'json',
            success: function (data) {
//                console.log(data);
                if(data){
//                    console.log(111)
                    $('#msg').show();
                }else{
//                    console.log(222)
                    $('#msg').hide();
                }
            },
            error: function () {
            }
        });



        msgtimer=setTimeout('showmsg()', 2000);
    }
</script>